/**
 * Copyright (C) 2011 Vinicius Vielmo Cogo, Marcelo Pasin, and the authors
 * indicated in the @author tags.
 * 
 * This file is part of DiversityAgent.
 * 
 * DiversityAgent is a free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 * 
 * DiversityAgent is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with DiversityAgent. If not, see <http://www.gnu.org/licenses/>.
 */
package diversity_agent;

import java.util.ArrayList;

/**
 * 
 * @author Vinicius Vielmo Cogo (vielmo at lasige.di.fc.ul.pt)
 * @version 0.1-beta
 * @since 2011-11-18
 * 
 */
public class Image
{
	private String				mImageName;
	private ArrayList<String>	mCloudNames;
	// private String mImagePath;
	// private String mOwner;
	// private String mVisibility;	// [private, public]
	// private String mVirtualizationType;	// [paravirtualized, 
												// full-virtualized]
	// private String mCompatibleHypervisors[]; // [xen, kvm, vmware, hyper-v, 
												// nova, virtualbox, etc]
	private String				mOsType;		// [linux, windows, solaris,
												// mac, etc]
	private String				mOsName;		// [ubuntu-9.10, debian-5.04,
												// gentoo-10.1, fedora-12, etc]
	// private String mKervelVersion; //[2.6.31-23-generic, 2.6.26-2-686, etc]
	// private String mArchitecture; //[i386, i686, x64]
	// private String mServices[]; //[cron, dhcp, dns, apache, tomcat, etc]
	// private String mLanguages[]; //[java, c, c++, python, ruby, etc]

	/**
	 * 
	 * @param theImageName
	 */
	public Image(String theImageName)
	{
		// [TODO] Fetch image information automatically based on image name
		String[] aTmpStrings = theImageName.split("#");
		if (aTmpStrings.length == 3) {
			this.mImageName = aTmpStrings[0];
			this.mOsType = aTmpStrings[1];
			this.mOsName = aTmpStrings[2];
			this.mCloudNames = new ArrayList<String>();
			// this.mImagePath = theImagePath;
			// this.mOwner = theOwner;
			// private String mVisibility;
			// this.mVirtualizationType;
			// this.mCompatibleHypervisors[];
			// this.mKervelVersion;
			// this.mArchitecture;
			// this.mServices[];
			// this.mLanguages[];
		}
	}

	/**
	 * 
	 * @return
	 */
	public String getName()
	{
		return mImageName;
	}

	/**
	 * 
	 * @return
	 */
	public ArrayList<String> getAllocatedClouds()
	{
		return this.mCloudNames;
	}

	/**
	 * 
	 * @return
	 */
	public String getOsType()
	{
		return this.mOsType;
	}

	/**
	 * 
	 * @return
	 */
	public String getOsName()
	{
		return this.mOsName;
	}

	/**
	 * 
	 * @param theCloud
	 */
	public void addCloud(String theCloud)
	{
		mCloudNames.add(theCloud);
	}

	/**
	 * 
	 * @param theCloud
	 */
	public void deleteCloud(String theCloud)
	{
		if (mCloudNames.contains(theCloud)) {
			mCloudNames.remove(theCloud);
		}
	}

	/**
	 * 
	 * @return
	 */
	public int getNumClouds()
	{
		return mCloudNames.size();
	}
}
